home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / dev / lang / perl4_035_v010.lzh / perl4.035 / cscript / cprogram.h next >
Text File  |  1992-08-31  |  1KB  |  39 lines

  1. char *gacCProgram[] = {
  2. "    char acTmp[BUFSIZ];\n",
  3. "    char *pcArgs=NULL;\n",
  4. "    char *pcTmp = NULL;\n",
  5. "    FILE *pFScript;\n",
  6. "\n",
  7. "    for(i=1; i<argc; i++) {\n",
  8. "    if(pcArgs == NULL) {\n",
  9. "        if((pcArgs = (char *)malloc(strlen(argv[i])+1)) == NULL) {\n",
  10. "        fprintf(stderr, \"%%s: *** Error - malloc failed\\n\", PROGRAM);\n",
  11. "            exit(1);\n",
  12. "        }\n",
  13. "        strcpy(pcArgs, argv[i]);\n",
  14. "    }\n",
  15. "    else {\n",
  16. "        if((pcTmp = (char *)malloc(strlen(argv[i])+strlen(pcArgs)+2)) == NULL) {\n",
  17. "        fprintf(stderr, \"%%s: *** Error - malloc failed\\n\", PROGRAM);\n",
  18. "        exit(1);\n",
  19. "        }\n",
  20. "        sprintf(pcTmp,\"%%s %%s\", pcArgs, argv[i]);\n",
  21. "        free(pcArgs);\n",
  22. "        pcArgs = pcTmp;\n",
  23. "    }\n",
  24. "    }\n",
  25. "\n",
  26. "    /*** Open temporary script file ***/\n",
  27. "    if((pFScript = fopen(SCRIPT, \"w\")) == NULL) { \n",
  28. "    fprintf(stderr, \"%%s: *** Error - can't open script file: %%s\\n\", PROGRAM, SCRIPT);\n",
  29. "    exit(1);\n",
  30. "    }\n",
  31. "    \n",
  32. "    for(i=0; gacScript[i] != NULL; i++) {\n",
  33. "    fprintf(pFScript, gacScript[i]);\n",
  34. "    }\n",
  35. "    fclose(pFScript);\n",
  36. "\n",
  37. NULL
  38. };
  39.